<template>
  <el-drawer v-model="addDrawer" size="45%" :show-close="false" @opened="openDrawer" @close="closeDrawer">
    <template #title>
      <h2><svg-icon icon-class="list"></svg-icon><span style="padding-left: 15px">{{ typeName }}</span></h2>
      <el-button type="primary" @click="confirmClick" :disabled="drawerLoading" v-if="isShowSave">保存</el-button>
    </template>
    <template #default>
      <el-form :model="form" ref="addRef" :inline="true" :rules="formRules" label-width="140px" v-loading="drawerLoading">
        <el-row justify="space-between">
          <el-form-item label="省">
            <el-input v-model="form.province" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="市">
            <el-input v-model="form.city" clearable disabled></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="区/县">
            <el-input v-model="form.county" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="编号" prop="id">
            <el-input v-model="form.id" placeholder="请输入编号" clearable maxlength="17"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="发震日期" prop="occurrenceDate">
            <el-input v-model="form.occurrenceDate" placeholder="请输入发震日期" clearable maxlength="20" />
          </el-form-item>
          <el-form-item label="发震时间" prop="occurrenceTime">
            <el-input v-model="form.occurrenceTime" placeholder="请输入发震时间" clearable maxlength="20"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="地名" prop="locationName" style="width: 100%">
            <el-input v-model="form.locationName" placeholder="请输入地名" :autosize="{ minRows: 2, maxRows: 4 }"
              type="textarea" show-word-limit maxlength="40" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="震中经度" prop="lon">
            <el-input v-model="form.lon" placeholder="请输入震中经度" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="震中纬度" prop="lat">
            <el-input v-model="form.lat" placeholder="请输入震中纬度" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="震级" prop="magnitude">
            <el-input v-model="form.magnitude" placeholder="请输入震级" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="震级单位 [Ms、Ml、Mw等]" prop="unit">
            <el-input v-model="form.unit" placeholder="请输入震级单位 [Ms、Ml、Mw等]" clearable maxlength="10"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="震源深度 [公里]" prop="depth">
            <el-input v-model="form.depth" placeholder="请输入震源深度 [公里]" clearable maxlength="8"></el-input>
          </el-form-item>
          <el-form-item label="水平最大主应力方位" prop="shazimuth">
            <el-input v-model.number="form.shazimuth" placeholder="请输入震级" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="应力状态" prop="stressRegime">
            <dict-select code="StressRegimeCVD" :value="form.stressRegime" @update="updateDict('stressRegime', $event)"></dict-select>
          </el-form-item>
          <el-form-item label="Ⅰ节面走向" prop="plane1Strike">
            <el-input v-model.number="form.plane1Strike" placeholder="请输入Ⅰ节面走向" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="Ⅰ节面倾角" prop="plane1Dip">
            <el-input v-model.number="form.plane1Dip" placeholder="请输入Ⅰ节面倾角" clearable maxlength="4"></el-input>
          </el-form-item>
          <el-form-item label="Ⅰ节面滑动角" prop="plane1Slip">
            <el-input v-model.number="form.plane1Slip" placeholder="请输入Ⅰ节面滑动角" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="Ⅱ节面走向" prop="plane2Strike">
            <el-input v-model.number="form.plane2Strike" placeholder="请输入Ⅱ节面走向" clearable maxlength="4"></el-input>
          </el-form-item>
          <el-form-item label="Ⅱ节面倾角" prop="plane2Dip">
            <el-input v-model.number="form.plane2Dip" placeholder="请输入Ⅱ节面倾角" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="Ⅱ节面滑动角" prop="plane2Slip">
            <el-input v-model.number="form.plane2Slip" placeholder="请输入Ⅱ节面滑动角" clearable maxlength="4"></el-input>
          </el-form-item>
          <el-form-item label="P轴方位" prop="pazimuth">
            <el-input v-model.number="form.pazimuth" placeholder="请输入P轴方位" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="P轴倾角" prop="pplunge">
            <el-input v-model.number="form.pplunge" placeholder="请输入P轴倾角" clearable maxlength="4"></el-input>
          </el-form-item>
          <el-form-item label="T轴方位" prop="tazimuth">
            <el-input v-model.number="form.tazimuth" placeholder="请输入T轴方位" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="T轴倾角" prop="tplunge">
            <el-input v-model.number="form.tplunge" placeholder="请输入T轴倾角" clearable maxlength="4"></el-input>
          </el-form-item>
          <el-form-item label="B轴方位" prop="bazimuth">
            <el-input v-model.number="form.bazimuth" placeholder="请输入B轴方位" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="B轴倾角" prop="bplunge">
            <el-input v-model.number="form.bplunge" placeholder="请输入B轴倾角" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="震源机制解的求解方法" prop="method" style="width:100%">
            <el-input v-model="form.method" placeholder="请输入震源机制解的求解方法" :autosize="{ minRows: 3, maxRows: 6 }"
              type="textarea" show-word-limit maxlength="100" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="资料来源" prop="reference" style="width:100%">
            <el-input v-model="form.reference" placeholder="请输入资料来源" :autosize="{ minRows: 4, maxRows: 8 }"
              type="textarea" show-word-limit maxlength="255" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="备注" prop="commentInfo" style="width:100%">
            <el-input v-model="form.commentInfo" placeholder="请输入备注" :autosize="{ minRows: 6, maxRows: 12 }"
              type="textarea" show-word-limit maxlength="2147483647" clearable></el-input>
          </el-form-item>
        </el-row>
      </el-form>
    </template>
  </el-drawer>
</template>
<script setup name="Pt13">
import useSpatialData from '@/hooks/useSpatialData'
import { rangeValidate, eightDouble } from '@/utils/validate'
const { route, addDrawer, drawerLoading, form, typeName, openDrawer, closeDrawer, confirmClick, updateDict, isShowSave } = useSpatialData()

const formRules = {
  id: [{ required: true, message: '请填写编号！', trigger: 'blur' }],
  occurrenceDate: [{ required: true, message: '请填写发震日期！', trigger: 'blur' }],
  lon: [{ required: true, message: '请填写震中经度！', trigger: 'blur' }, eightDouble],
  lat: [{ required: true, message: '请填写震中纬度！', trigger: 'blur' }, eightDouble],
  magnitude: [{ required: true, message: '请填写震级！', trigger: 'blur' }, eightDouble],
  depth: [eightDouble],
  shazimuth: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 359, validator: rangeValidate }],
  plane1Strike: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 359, validator: rangeValidate }],
  plane1Dip: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 90, validator: rangeValidate }],
  plane1Slip: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 359, validator: rangeValidate }],
  plane2Strike: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 359, validator: rangeValidate }],
  plane2Dip: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 90, validator: rangeValidate }],
  plane2Slip: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 359, validator: rangeValidate }],
  pazimuth: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 359, validator: rangeValidate }],
  pplunge: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 90, validator: rangeValidate }],
  tazimuth: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 359, validator: rangeValidate }],
  tplunge: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 90, validator: rangeValidate }],
  bazimuth: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 359, validator: rangeValidate }],
  bplunge: [{ type: 'number', message: '请输入整数' }, { min: 0, max: 90, validator: rangeValidate }]
}
</script>
<style scoped></style>